#+TITLE: Emacs configuration
#+AUTHOR: Carlos Martinez
#+EMAIL: jcmartinez2129@protonmail.org

* Configure use-package
#+BEGIN_SRC emacs-lisp
(require 'use-package-ensure)
(setq use-package-always-ensure t)
#+END_SRC

Always compile packages and use the latest version available
#+BEGIN_SRC emacs-lisp
(use-package auto-compile
  :config (auto-compile-on-load-mode))

(setq load-prefer-newer t)
#+END_SRC
* Basic Configuration
** Unnecessary GUI stuff
Many things in the default emacs GUI are just excesive,
such as the =menu-bar-mode=, =tool-bar-mode= and =scroll-bar-mode=
to eliminate them you can do:
#+BEGIN_SRC emacs-lisp
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
#+END_SRC

Disable tiny scroll bar that appears in the minibuffer

#+BEGIN_SRC emacs-lisp
(set-window-scroll-bars (minibuffer-window) nil nil)
#+END_SRC

Frame title to something useful

#+BEGIN_SRC emacs-lisp
(setq frame-title-format '("Emacs"))
#+END_SRC

** Use fancy lambdas
Why not?

#+BEGIN_SRC emacs-lisp
(global-prettify-symbols-mode t)
#+END_SRC

** Theme and font
*** Font
Leaving the default  font for now
*** Theme
For theme, I think misterioso is my favourite out of
the themes included in emacs
#+BEGIN_SRC emacs-lisp
(load-theme 'gruvbox-dark-medium t)
#+END_SRC

** Highlight the current line
=global-hl-line-mode= softly highlights the background color of the line
containing your point
#+BEGIN_SRC emacs-lisp
(global-hl-line-mode)
#+END_SRC
** Adding some nice extras
=ido-mode= is a nice way to navigate your filesystem from emacs
while opening a file
#+BEGIN_SRC emacs-lisp
(ido-mode)
(column-number-mode)
(winner-mode t)
#+END_SRC
** Backup files
By default emacs ads a backup file in the same directory of the file,
this can be anoying so let's fix it
#+BEGIN_SRC emacs-lisp
(setq backup-directory-alist '(("." . "~/.backups")))
#+END_SRC
** Matching parenthesis
To match parenthesis a great way is to use =electric-pair-mode=
#+BEGIN_SRC emacs-lisp
(electric-pair-mode)
#+END_SRC
** Read epub files wiht nov mode
Use nov mode to read epub files
#+BEGIN_SRC emacs-lisp
(add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))
#+END_SRC

** Enable evil-mode
#+BEGIN_SRC emacs-lisp
(add-to-list 'load-path "~/.emacs.d/evil")
(require 'evil)
(evil-mode 1)
#+END_SRC

* Org mode configs
** Pretty bullets

#+BEGIN_SRC emacs-lisp
(use-package org-bullets
  :init
  (add-hook 'org-mode-hook 'org-bullets-mode))
#+END_SRC

I like seeing a little downward-pointing arow instead of the usual
ellipsis (...)

#+BEGIN_SRC emacs-lisp
(setq org-ellipsis "⤵")
#+END_SRC

use syntax highlighting in source blocks while editing
#+BEGIN_SRC emacs-lisp
(setq org-src-fontify-natively t)
#+END_SRC

** Exporting to HTML
Don't include a footer with my contact and publishing information
at the bottom of every html document

#+BEGIN_SRC emacs-lisp
(setq org-html-postamble nil)
#+END_SRC

Using Abrowser as default browser to view html

#+BEGIN_SRC emacs-lisp
(setq browse-url-browser-function 'browse-url-generic
      browse-url-generic-program "abrowser")

(setenv "BROWSER" "abrowser")
#+END_SRC
* Remote Editing
Use TRAMP to edit remote files
#+BEGIN_SRC emacs-lisp
(setq tramp-default-method "ssh")
#+END_SRC
This will help to use ssh by default
* Specific languages
** Perl
These are some  instructions to use perl
#+BEGIN_SRC emacs-lisp
;; Use cperl-mode instead of the default perl-mode
(mapc
  (lambda (pair)
    (if (eq (cdr pair) 'perl-mode)
        (setcdr pair 'cperl-mode)))
  (append auto-mode-alist interpreter-mode-alist))

(defun n-cperl-mode-hook ()
  (setq cperl-indent-level 4)
  (setq cperl-continued-statement-offset 0)
  (setq cperl-extra-newline-before-brace t)
  (set-face-background 'cperl-array-face "wheat")
  (set-face-background 'cperl-hash-face "wheat")
  )

#+END_SRC
